
function selectProductBack(rows) {
	var html = "";
	for ( var i = 0; i < rows.length; i++) {
		html = '<tr>'
		+'<td style="display:none"><input type="hidden" name="orderProductList[#index#].productId.id" value="'+rows[i].id+'"/></td>'
		+'<td ><input style="width: 20px;" type="checkbox" name="ck" /></td>'
		+'<td >'+rows[i].name+'</td>'
		+'<td >aaaa</td>'
		+'<td >'+rows[i].manufacturer+'</td>'
		+'<td >'+rows[i].model+'</td>'
		+'<td >'+rows[i].specification+'</td>'
<<<<<<< HEAD
		+'<td ><input datatype="*" style="width: 60px;" type="text" name="orderProductList[#index#].amount" value="1" /></td>'
		+'<td ><input datatype="*" style="width: 60px;" type="text" name="orderProductList[#index#].price" value="'+rows[i].basedCost+'" /></td>'
		+'<td ><input datatype="*" style="width: 60px;" type="text" name="orderProductList[#index#].totalPrice" value="'+rows[i].basedCost+'" /></td>'
=======
		+'<td ><input datatype="*" style="width: 60px;" type="text" name="orderProductList[#index#].amount" onblur="compute([#index#])" value="1" /></td>'
		+'<td ><input datatype="*" style="width: 60px;" type="text" name="orderProductList[#index#].price" onblur="compute([#index#])" value="'+rows[i].basedCost+'" /></td>'
		+'<td ><input datatype="*" style="width: 60px;" type="text" name="orderProductList[#index#].totalPrice" onblur="compute([#index#])" value="'+rows[i].basedCost+'" /></td>'
>>>>>>> a9c7731b4788b28c37d962faa7843e2cac438e61
		+'</tr>';
		
		$("#add_orderProduct_table").append(html);
		resetTrNum('add_orderProduct_table');
	}
	
}
function delBtnClick() {
	
	$("#add_orderProduct_table").find("input:checked").parent().parent().remove();
	resetTrNum('add_orderProduct_table');
}
$(document).ready(function() {
	$(".datagrid-toolbar").parent().css("width", "auto");
	// 将表格的表头固定
		$("#product_table").createhftable( {
			height : '400px',
			width : 'auto',
			fixFooter : false
		});
	});

// 初始化下标
function resetTrNum(tableId) {
	$tbody = $("#" + tableId + "");
	$tbody.find('>tr').each(function(i) {
		$(':input, select', this).each(function() {
			var $this = $(this), name = $this.attr('name'), val = $this.val();
			if (name != null) {
				if (name.indexOf("#index#") >= 0) {
					$this.attr("name", name.replace('#index#', i));
				} else {
					var s = name.indexOf("[");
					var e = name.indexOf("]");
					var new_name = name.substring(s + 1, e);
					$this.attr("name", name.replace(new_name, i));
				}
			}
		});
<<<<<<< HEAD
	});
=======
		//事件监听
		$(':input, select', this).each(function() {
			var $this = $(this), name = $this.attr('onblur'), val = $this.val();
			if (name != null) {
				if (name.indexOf("#index#") >= 0) {
					$this.attr("onblur", name.replace('#index#', i));
				} else {
					var s = name.indexOf("[");
					var e = name.indexOf("]");
					var new_name = name.substring(s + 1, e);
					$this.attr("onblur", name.replace(new_name, i));
				}
			}
		});
	});
	
	  var allPrice=0;
      $tbody.find('>tr').each(function(i) {
			 allPrice=Number(allPrice)+Number( $("input[name='orderProductList["+i+"].totalPrice']").val());
		});
		
		$("input[name='totalPrice").val(allPrice);
>>>>>>> a9c7731b4788b28c37d962faa7843e2cac438e61
}
